package com.hzgj.soa.spring.schema;

import com.hzgj.soa.spring.RegistryBean;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

public class RegistryDefBeanDefinitionParser extends AbstractBeanDefinitionParser {

    public RegistryDefBeanDefinitionParser(Class<?> beanClass, boolean required) {
        super(beanClass, required);
    }

    @Override
    void parse0(RootBeanDefinition beanDefinition, Element element, ParserContext parserContext, Class<?> beanClass) {
        SoaNamespaceHandler.setBeanProperty(beanDefinition, element);
        RootBeanDefinition registryBeanDefinition = new RootBeanDefinition();
        registryBeanDefinition.setBeanClass(RegistryBean.class);
        registryBeanDefinition.setLazyInit(false);
        parserContext.getRegistry().registerBeanDefinition(RegistryBean.class.getSimpleName(), registryBeanDefinition);
    }
}